/**
 * 配置路由
 * author: Wanghui <wangh@ciqtek.com>
 * company: ubiot.cn
 * date: 2019-08-10
 */

export const asyncComponents = {
  /**manage 部分 */
  Home: () => import(/* webpackChunkName: "home" */ '@/views/manage/Home.vue'),
  About: () => import(/* webpackChunkName: "about" */ '@/views/manage/About.vue'),
  Invest: () => import(/* webpackChunkName: "invest" */ '@/views/manage/Invest.vue'),
  Pay: () => import(/* webpackChunkName: "pay" */ '@/views/manage/Pay.vue'),
  InvestDetail: () => import(/* webpackChunkName: "investDetail" */ '@/views/manage/InvestDetail.vue'),

  /**service 部分 */
  Dashboard: () => import(/* webpackChunkName: "dashboard" */ '@/views/service/Dashboard.vue')
}

export type AsyncComponentKeys = keyof typeof asyncComponents

export interface IRoot {
  name: string
  key: string
  icon: string
}

/**
 * 顶部一级导航
 * @type {IRoot[]}
 */
export const rootList: IRoot[] = [
  {
    name: "menu.manage",
    key: "manage",
    icon: "bars"
  },
  {
    name: "menu.service",
    key: "service",
    icon: "desktop"
  }
]

export interface IMenu {
  title: string
  id: number
  pid?: number
  root?: string
  path?: string
  icon?: string
  name?: string
  component: AsyncComponentKeys
  exact?: boolean
  meta: Object
}

/**
 * 所有路由数据管理
 * @type {IMenu[]}
 */
export const menu: IMenu[] = [
  {
    id: 1,
    root: "manage",
    path: 'home',
    title: 'menu.home',
    name: 'home',
    icon: 'home',
    component: 'Home',
    meta: {
      bread: [
        { label: 'menu.home', path: null }
      ]
    },
    exact: true
  },
  {
    id: 2,
    root: "manage",
    path: 'about',
    title: 'menu.about',
    name: 'about',
    icon: 'bar-chart',
    component: 'About',
    meta: {
      bread: [
        { label: 'menu.about', path: null }
      ]
    },
    exact: true
  },
  {
    id: 3,
    root: "manage",
    icon: 'ordered-list',
    title: 'menu.order',
    exact: false,
    // @ts-ignore
    component: null,
    meta: {}
  },
  {
    id: 4,
    pid: 3,
    root: "manage",
    path: "invest",
    title: 'menu.orderInvest',
    name: 'order-invest',
    icon: 'file',
    component: 'Invest',
    meta: {
      bread: [
        { label: 'menu.orderInvest', path: null }
      ]
    },
    exact: true
  },
  {
    id: 5,
    pid: 0,
    root: "manage",
    path: "investDetail/:id",
    title: 'menu.orderInvestDetail',
    name: 'order-invest-detail',
    icon: 'ordered-list',
    component: 'InvestDetail',
    meta: {
      bread: [
        { label: 'menu.orderInvest', path: "order-invest" },
        { label: 'menu.orderInvestDetail', path: null }
      ]
    },
    exact: true
  },
  {
    id: 6,
    pid: 3,
    root: "manage",
    path: "pay",
    title: 'menu.orderPay',
    name: 'order-pay',
    icon: 'file',
    component: 'Pay',
    meta: {
      bread: [
        { label: 'menu.orderPay', path: null }
      ]
    },
    exact: true
  },
  {
    id: 7,
    root: "service",
    path: "dashboard",
    title: 'menu.dashboard',
    name: 'dashboard',
    icon: 'dashboard',
    component: 'Dashboard',
    meta: {
      bread: [
        { label: 'menu.dashboard', path: null }
      ]
    },
    exact: true
  }
]
